package com.wanmait.jd.dao;

import com.wanmait.jd.util.DBHelper;
import com.wanmait.jd.vo.Province;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class ProvinceDAO {
    public List<Province> findAll(){
        QueryRunner queryRunner = new QueryRunner(DBHelper.getDruidDataSource());

        String sql = "select * from province";

        try {
            List<Province> provinceList = queryRunner.query(sql, new BeanListHandler<Province>(Province.class));
            return provinceList;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
